package com.utility.project.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO;
import com.utility.project.entity.YsExam;
import com.utility.project.entity.YsPaper;
import com.utility.project.mapper.YsExamMapper;
import com.utility.project.param.ExamParam;
import com.utility.project.service.IYsExamService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author yangzhiguo
 * @date 2024-06-22
 * @description 试题
 */
@Service
public class YsExamServiceImpl extends ServiceImpl<YsExamMapper, YsExam> implements IYsExamService {

    @Override
    public IPage<YsExam> queryExamByParam(ExamParam examParam) {
        String paperId = examParam.getPaperId();
        Page<YsExam> pageDTO  = new Page<>(examParam.getPageIndex(), examParam.getPageSize());
        QueryWrapper<YsExam> query = new QueryWrapper<>();
        if(StrUtil.isNotBlank(paperId)){
            query.eq("paper_id", paperId);
        }
        return baseMapper.selectPage(pageDTO, query);
    }
}
